<?php get_header() ?>
<?php 

	global $wpdb; 
    $xuser = $wpdb->get_row("SELECT * FROM ap_painting_user WHERE  user_id = {$_SESSION['user_id']}");
	
	if(isset($xuser->id)){ 
    ?>
    <ul class="userinfo">
        <li><?php echo $xuser->name ?></li>
        <li><?php echo $xuser->birthday ?></li>
       
    </ul>
   
<?php } else { ?>
    <div class="register">
        <form action="" method="post" id="registerform" >
            <input type="text"  name="xusername"   id="tenpe" value="" placeholder="Tên bé" />
            <div class="birth">
                <select name="xday" >
                    <?php for ($i = 1; $i <= 31; $i++) { ?>
                        <option><?php echo $i < 10 ? '0' . $i : $i ?></option>
                    <?php } ?>
                </select>
                <select name="xmonth"  >
                    <?php for ($i = 1; $i <= 12; $i++) { ?>
                        <option>Tháng <?php echo $i ?></option>
                    <?php } ?>
                </select>
                <select name="xyear"  >
                    <?php for ($i = 1997; $i <= 2013; $i++) { ?>
                        <option > <?php echo $i ?></option>
                    <?php } ?>
                </select>
                <div style="clear:both; "></div>
            </div> <br />
            <input type="button" id="submitbt"  value="&nbsp;" />
        </form>
    </div>
<?php } ?>
<script type="text/javascript">
    jQuery(document).ready(function() {
        jQuery('#submitbt').click(function() {
            if (jQuery('#tenpe').val() === '') {
                alert(' Chưa nhập tên bé ! ');
                jQuery('#tenpe').focus();
            } else {

                jQuery.post("<?php echo site_url() ?>/registeruser/",
                        jQuery('#registerform').serialize(),
                        function() {
                          
                            document.location.href = "<?php echo site_url() ?>/the-le";
                        });
            }

        });
    });
</script>
<?php get_footer() ?>